<?php
defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE.'/'.MODULE_NAME.'/common.inc.php';
$table = Table::name(Table::NAME_BUSINESS);
$itemid or dheader($MOD['linkurl']);
$sqlItem = "SELECT * FROM {$table} WHERE itemid=$itemid";
$item = $db->getOne($sqlItem);
//在线状态
$user = userinfo($item['username']);
$online = online($user['userid']);
$CATEGORY = PCache::read('category-33.php');
$sql = "select * from {$table} where userid={$item['userid']} order by mainstore DESC";
$allItem = $db->getAll($sql);
if($item && $item['status'] >= 2) {

} else {
	$head_title = lang('message->item_not_exists');
	@header("HTTP/1.1 404 Not Found");
	exit(include template('show-notfound', 'message'));
}
$CAT = get_cat($catid);
if(!check_group($_groupid, $MOD['group_show']) || !check_group($_groupid, $CAT['group_show'])) {
	$head_title = lang('message->without_permission');
	exit(include template('noright', 'message'));
}


$sqlContent = "SELECT content FROM ".$db->getPre()."business_data WHERE itemid={$itemid}";
$t = $db->getOne($sqlContent);
$content = $t['content'];
$adddate = timetodate($addtime, 3);
$editdate = timetodate($edittime, 3);
$todate = $totime ? timetodate($totime, 3) : 0;
$expired = $totime && $totime < $DT_TIME ? true : false;
$linkurl = linkurl($linkurl, 1);
$albums = $db->getAll("select * from ".Table::name(Table::NAME_BUSINESS_PICTURE) . " where userid = {$item['userid']} order by addtime desc limit 5");
$amount = number_format($amount, 0, '.', '');
$fee = get_fee($item['fee'], $MOD['fee_view']);
$update = '';
if(check_group($_groupid, $MOD['group_contact'])) {
	if($fee) {
		$user_status = 4;
	} else {
		$user_status = 3;
		$member = $item['username'] ? userinfo($item['username']) : array();
		if($item['totime'] && $item['totime'] < $DT_TIME && $item['status'] == 3) {
			$update .= ",status=4";
			$db->query("UPDATE {$table}_search SET status=4 WHERE itemid=$itemid");
		}
		if($member) {
			foreach(array('groupid', 'vip','validated','company','areaid','truename','telephone','mobile','address','qq','msn','ali','skype') as $v) {
				if($item[$v] != $member[$v]) $update .= ",$v='".addslashes($member[$v])."'";
			}
			if($item['email'] != $member['mail']) $update .= ",email='$member[mail]'";
		}
	}
} else {
	$user_status = $_userid ? 1 : 0;
	if($_username && $item['username'] == $_username) {
		$member = userinfo($item['username']);
		$user_status = 3;
	}
}

include DT_INC.'/update.inc.php';
$seo_file = 'show';
$title = $item['shopname'];
include DT_INC.'/seo.inc.php';
include template('show', MODULE_NAME);